<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# OPTIONS_HADDOCK hide #-}</span><span class="hs-cpp">

#include &quot;containers.h&quot;
</span><span>
</span><span id="line-6"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Utils.Containers.Internal.Coercions</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#if __GLASGOW_HASKELL__ &gt;= 708
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Coerce.html#"><span class="hs-identifier">Data.Coerce</span></a></span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-12"></span><span class="hs-keyword">infixl</span><span> </span><span class="hs-number">8</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.Coercions.html#.%23"><span class="hs-operator hs-type">.#</span></a></span><span class="hs-cpp">
#if __GLASGOW_HASKELL__ &gt;= 708
</span><span id="local-6989586621679158407"><span id="local-6989586621679158408"><span id="local-6989586621679158409"><span class="annot"><a href="Utils.Containers.Internal.Coercions.html#.%23"><span class="hs-operator hs-type">(.#)</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Coercible</span></span><span> </span><span class="annot"><a href="#local-6989586621679158409"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679158408"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679158409"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679158407"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679158408"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679158409"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679158408"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679158407"><span class="hs-identifier hs-type">c</span></a></span></span></span></span><span>
</span><span id="line-15"></span><span id=".%23"><span class="annot"><span class="annottext">.# :: forall b a c. Coercible b a =&gt; (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="Utils.Containers.Internal.Coercions.html#.%23"><span class="hs-operator hs-var hs-var">(.#)</span></a></span></span><span> </span><span id="local-6989586621679158388"><span class="annot"><span class="annottext">b -&gt; c
</span><a href="#local-6989586621679158388"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="annot"><span class="annottext">a -&gt; b
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(b -&gt; c) -&gt; a -&gt; c
</span><span class="hs-identifier hs-var">coerce</span></span><span> </span><span class="annot"><span class="annottext">b -&gt; c
</span><a href="#local-6989586621679158388"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-cpp">
#else
</span><span class="hs-special">(</span><span class="hs-operator">.#</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">b</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">c</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">b</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">c</span><span>
</span><span id="line-18"></span><span class="hs-special">(</span><span class="hs-operator">.#</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-operator">.</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">(</span><span class="hs-pragma">.#</span><span class="hs-pragma">)</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-21"></span><span>
</span><span id="line-22"></span><span class="hs-keyword">infix</span><span> </span><span class="hs-number">9</span><span> </span><span class="annot"><a href="Utils.Containers.Internal.Coercions.html#.%5E%23"><span class="hs-operator hs-type">.^#</span></a></span><span>
</span><span id="line-23"></span><span>
</span><span id="line-24"></span><span class="hs-comment">-- | Coerce the second argument of a function. Conceptually,</span><span>
</span><span id="line-25"></span><span class="hs-comment">-- can be thought of as:</span><span>
</span><span id="line-26"></span><span class="hs-comment">--</span><span>
</span><span id="line-27"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-28"></span><span class="hs-comment">--   (f .^# g) x y = f x (g y)</span><span>
</span><span id="line-29"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-30"></span><span class="hs-comment">--</span><span>
</span><span id="line-31"></span><span class="hs-comment">-- However it is most useful when coercing the arguments to</span><span>
</span><span id="line-32"></span><span class="hs-comment">-- 'foldl':</span><span>
</span><span id="line-33"></span><span class="hs-comment">--</span><span>
</span><span id="line-34"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-35"></span><span class="hs-comment">--   foldl f b . fmap g = foldl (f .^# g) b</span><span>
</span><span id="line-36"></span><span class="hs-comment">-- @</span><span class="hs-cpp">
#if __GLASGOW_HASKELL__ &gt;= 708
</span><span id="local-6989586621679158397"><span id="local-6989586621679158398"><span id="local-6989586621679158399"><span id="local-6989586621679158400"><span class="annot"><a href="Utils.Containers.Internal.Coercions.html#.%5E%23"><span class="hs-operator hs-type">(.^#)</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Coercible</span></span><span> </span><span class="annot"><a href="#local-6989586621679158400"><span class="hs-identifier hs-type">c</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679158399"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679158398"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679158400"><span class="hs-identifier hs-type">c</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679158397"><span class="hs-identifier hs-type">d</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679158399"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679158400"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679158398"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679158399"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679158397"><span class="hs-identifier hs-type">d</span></a></span><span class="hs-special">)</span></span></span></span></span><span>
</span><span id="line-39"></span><span id=".%5E%23"><span class="annot"><span class="annottext">.^# :: forall c b a d.
Coercible c b =&gt;
(a -&gt; c -&gt; d) -&gt; (b -&gt; c) -&gt; a -&gt; b -&gt; d
</span><a href="Utils.Containers.Internal.Coercions.html#.%5E%23"><span class="hs-operator hs-var hs-var">(.^#)</span></a></span></span><span> </span><span id="local-6989586621679158383"><span class="annot"><span class="annottext">a -&gt; c -&gt; d
</span><a href="#local-6989586621679158383"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="annot"><span class="annottext">b -&gt; c
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a -&gt; c -&gt; d) -&gt; a -&gt; b -&gt; d
</span><span class="hs-identifier hs-var">coerce</span></span><span> </span><span class="annot"><span class="annottext">a -&gt; c -&gt; d
</span><a href="#local-6989586621679158383"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-cpp">
#else
</span><span class="hs-special">(</span><span class="hs-operator">.^#</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">c</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">d</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">b</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">c</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">b</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">d</span><span class="hs-special">)</span><span>
</span><span id="line-42"></span><span class="hs-special">(</span><span class="hs-identifier">f</span><span> </span><span class="hs-operator">.^#</span><span> </span><span class="hs-identifier">g</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-identifier">y</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">f</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">g</span><span> </span><span class="hs-identifier">y</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">(</span><span class="hs-pragma">.^#</span><span class="hs-pragma">)</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-45"></span></pre></body></html>